using System;
using Tarkin.InfrastructureLibrary.Core.PrimitiveTypes;
using Tarkin.InfrastructureLibrary.Tests.Core.Basic.TestUtilities.ConcreteClasses;
using NUnit.Framework;

namespace Tarkin.InfrastructureLibrary.Tests.Core.Basic.TestUtilities
{
    /// <summary>
    /// MultiplicityElementTests is the NUnit TestFixture for the Tarkin.InfrastructureLibrary.Core.Basic.MultiplicityElement class.
    /// </summary>
    [TestFixture]
    public class MultiplicityElementTests
    {
        [Test]
        public void TestLowerProperty ()
        {
            ConcreteMultiplicityElement multiplicityElement = new ConcreteMultiplicityElement ();
            UnlimitedNatural unlimitedNatural = new UnlimitedNatural ( "14" );

            multiplicityElement.Upper = unlimitedNatural;
            multiplicityElement.Lower = 12;

            Assert.AreEqual ( 12, multiplicityElement.Lower );
        }

        [Test]
        public void TestUpperProperty ()
        {
            ConcreteMultiplicityElement multiplicityElement = new ConcreteMultiplicityElement ();
            UnlimitedNatural unlimitedNatural = new UnlimitedNatural ( "14" );

            multiplicityElement.Upper = unlimitedNatural;

            Assert.AreEqual ( "14", multiplicityElement.Upper.Value );
        }

        [Test]
        [ExpectedException ( typeof ( ArgumentException ) )]
        public void TestLowerPropertyThrowException ()
        {
            ConcreteMultiplicityElement multiplicityElement = new ConcreteMultiplicityElement ();
            UnlimitedNatural unlimitedNatural = new UnlimitedNatural ( "14" );

            multiplicityElement.Upper = unlimitedNatural;
            multiplicityElement.Lower = 16;
        }

        [Test]
        [ExpectedException ( typeof ( ArgumentNullException ) )]
        public void TestUpperPropertyNullValue ()
        {
            ConcreteMultiplicityElement multiplicityElement = new ConcreteMultiplicityElement ();

            multiplicityElement.Upper = null;
        }

        [Test]
        [ExpectedException ( typeof ( ArgumentException ) )]
        public void TestUpperPropertyThrowException ()
        {
            ConcreteMultiplicityElement multiplicityElement = new ConcreteMultiplicityElement ();
            UnlimitedNatural unlimitedNatural = new UnlimitedNatural ( "0" );

            multiplicityElement.Upper = unlimitedNatural;
        }
    }
}
